#include<bits/stdc++.h>
using namespace std;
const int SIZE = 100005;
int t, n, m, l, mv, d[SIZE], v[SIZE], a[SIZE], p[SIZE], ans;
unordered_map<int, int>mp;
int main() {
    //freopen("detect.in", "r", stdin);
    //freopen("detect.out", "w", stdout);
    cin >> t;
    while (t--) {
        cin >> n >> m >> l >> mv;
        ans = 0;
        mp.clear();
        for (int i = 1; i <= n; i++) cin >> d[i] >> v[i] >> a[i];
        for (int i = 1; i <= m; i++) cin >> p[i];
        for (int i = 1; i <= n; i++) {
            bool le = 0;
            int leid = -1;
            for (int j = 1; j <= m; j++) {
                if (p[j] < d[i]) continue;
                int y = v[i] * v[i] + 2 * a[i] * (p[j] - d[i]), x = sqrt(y);
                if (x >= mv && x * x != y) {
                    if (mp[j] > 0) {
                        le = 0;
                        mp[j]++, ans++;
                        break;
                    }
                    else {
                        le = 1;
                        if(leid == -1) leid = j;
                    }
                }
            }
            if (le) ans++, mp[leid]++;
        }
        for (auto i : mp) cout << i.first << " ";
        cout << "\n" << ans << " " << m - mp.size();
    }
}
